package com.lrl.service;

import com.lrl.dao.UserMapper;
import com.lrl.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {
    UserMapper userMapper;

    @Autowired
    public void setUserMapper(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public boolean loginChecked(User user) {
        String name = user.getUsername();
        String pwd = user.getPassword();

        if (userMapper.getUserName(name).size() == 0) {
            return false;
        } else {
            return userMapper.getPwdByName(name).equals(pwd);
        }
    }

    @Override
    public boolean checkName(String name) {
        return userMapper.getUserName(name).size() != 0;
    }
}
